<?php
namespace Admin\Controller;
use Think\Controller;
class UtilController extends Controller {
    public function upload(){
    	$upload = new \Think\Upload();// 实例化上传类
    	$upload->maxSize = 5*1024*1024 ;// 设置附件上传大小    
    	$upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型    
    	$upload->rootPath = './Public/upload/'; // 设置附件上传目录    // 上传单个文件     
    	$info = $upload->uploadOne($_FILES['file']);
    	if(!$info) {// 上传错误提示错误信息        
    		echo $upload->getError();  
    	}else{// 上传成功 获取上传文件信息         
    		echo '/Public/upload/'.$info['savepath'].$info['savename'];    
    	}
    }
    public function uploadJson(){
        $upload = new \Think\Upload();// 实例化上传类
        $upload->maxSize = 5*1024*1024 ;// 设置附件上传大小    
        $upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型    
        $upload->rootPath = './Public/upload/'; // 设置附件上传目录    // 上传单个文件     
        $info = $upload->uploadOne($_FILES['imgFile']);
        if(!$info) {// 上传错误提示错误信息
            $this->ajaxReturn(array('error' => 1, 'message' => $upload->getError()));
        }else{// 上传成功 获取上传文件信息      
            $this->ajaxReturn(array('error' => 0, 'url' => 'Public/upload/'.$info['savepath'].$info['savename']));
        }
    }
}